// template/jihua/jihua.js
const util = require('../../utils/util');
Page({

    /**
     * 页面的初始数据
     */
    data: {
        aijiuxueweiStr: '',
        mzajrStr: '',
        jhmzajrStr:'',
        jihuatime:'',
        namestr: '',
        jhcurrentItem: {
            createTime: "2024-05-15 23:39:36",
            fangan1: ["百会穴", "安眠穴", "三阴交", "神门穴"],
            fangan2: [" 神阙穴 "],
            id: 1,
            isDeleted: false,
            jhmzajr: {
                0: true,
                1: false,
                2: true,
                3: false,
                4: true,
                5: false,
                6: true
            },
            mubiao: "快乐",
            name: "最新测试",
            nickname: "星月",
            openid: "oMB9T41dIwWcCcyUfpwpou_N464o",
            sex: "女",
            sfwc: "未完成",
            txtime: "08:00",
            updateTime: "2024-05-15 23:39:36",
            zhouqiend: "1715787550310",
            zhouqistar: "1715787550310",
            selectfangan: '方案一'
        },
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        const jhcurrentItem = wx.getStorageSync('jhcurrentItem')
        console.log('开始计划页面数据', jhcurrentItem)
        const fangan1 = JSON.parse(jhcurrentItem.fangan1)
        const fangan2 = JSON.parse(jhcurrentItem.fangan2)
        const jhmzajr = JSON.parse(jhcurrentItem.jhmzajr)
        let aijiuxueweiStr = ''
        let mzajrStr = ''

        const jhmzajrArr = []
        let jhmzajrStr = ''

        let jihuatime = '2024.10.10-2025.10.19'

        jihuatime = util.formatTime(new Date(Number(jhcurrentItem.zhouqistar))) + '-' +util.formatTime(new Date(Number(jhcurrentItem.zhouqiend)))
        if (jhmzajr[0]) {
            jhmzajrArr.push('周日')
        }
        if (jhmzajr[1]) {
            jhmzajrArr.push('周一')
        }
        if (jhmzajr[2]) {
            jhmzajrArr.push('周二')
        }
        if (jhmzajr[3]) {
            jhmzajrArr.push('周三')
        }
        if (jhmzajr[4]) {
            jhmzajrArr.push('周四')
        }
        if (jhmzajr[5]) {
            jhmzajrArr.push('周五')
        }
        if (jhmzajr[6]) {
            jhmzajrArr.push('周六')
        }
        jhmzajrStr = jhmzajrArr.join('、')

        if (jhcurrentItem.selectfangan == '方案一') {
            aijiuxueweiStr = fangan1.join('、')
        }
        if (jhcurrentItem.selectfangan == '方案二') {
            aijiuxueweiStr = fangan2.join('、')
        }
        this.setData({
            aijiuxueweiStr,
            mzajrStr,
            jhmzajrStr,
            jihuatime,
            namestr: jhcurrentItem.name,
        })
    },

    // 开始
    kaishijihua() {
        // wx.navigateTo({
        //     url: './aijiu/aijiu',
        // })
        wx.navigateTo({
            url: './aijiu2/aijiu2',
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})